package dao;

import entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author 石小俊
 * @date 2023年07月20日 13:44
 */
public interface IUserDao {

    @Insert(value = "insert into t_user(username,password,phone,address) values (#{username},#{password},#{phone},#{address})")
    void insertUser(User user);

    @Select("select id,username,password,phone,address from t_user")
    List<User> selectAll();

    @Select("select * from t_user2 where user_id = #{id}")
    @Results(value = {
            @Result(id = true,property = "id",column = "user_id"),
            @Result(property = "username",column = "user_username"),
            @Result(property = "password",column = "user_password"),
            @Result(property = "phone",column = "user_phone"),
            @Result(property = "address",column = "user_address")
    })
    User selectById(Integer id);

}
